<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%>
<html>
<body class="easyui-layout list_body">
	<form id="menuForm" name="menuForm">
		<div class="list_body_north" data-options="region:'north'" border="false">
			<!-- 查询表单 -->
			<div style="padding: 3px" class="easyui-panel datagrid-toolbar">
				<div>
					<span>清算开始日期:</span>
					<input type="text" id="stl_dt_start" value="${yestedayDate}" name="stl_dt_start" class="easyui-datebox" data-options="editable:false"/>
					<span>清算结束日期:</span>
					<input type="text" id="stl_dt_end" value="${yestedayDate}" name="stl_dt_end" class="easyui-datebox" data-options="editable:false"/>
					<span>机构号:</span>
					<input type="text" id="ins_cd" name="ins_cd" class="easyui-textbox" /> 
					<a href="#" class="easyui-linkbutton btn" iconCls="icon-search" onclick="doSearch()">查询</a> 
					<a href="#" class="easyui-linkbutton btn" iconCls="icon-reload" onclick="resetForm()">重置</a>
				</div>
			</div>
			<!-- 维护汇总数据 -->
			<div style="padding: 3px" class="easyui-panel datagrid-toolbar">
				交易金额汇总：<span id="all_amt"></span> 
				会员手续费汇总：<span id="all_midfee"></span> 
				会员结算手续费汇总：<span id="all_custom_stl_fee"></span> 
				机构结算手续费汇总：<span id="all_ins_stl_fee"></span> 
				毛利汇总：<span id="all_gross_profit"></span>
			</div>
			<jiepos:buttonOperateTag menuCode="${menuCode }"></jiepos:buttonOperateTag>
		</div>
		<div data-options="region:'center'" border="false" class="list_body_center">
			<!-- 表格 -->
			<table id="menuTableId" fit="true"></table>
		</div>
	</form>
</body>
<script type="text/javascript">
	var grid;
	$(function() {
		getTotalInfo();
		/*加载表格数据*/
		grid = $("#menuTableId").jpgrid({
			url : "getLogStlInsSumListJson.do",
			baseColumns: false,
			columns : [ {
				title : "清算日期",
				field : "STL_DT",
				align : 'center',
				width : 100
			}, {
				title : "机构号",
				field : "INS_CD",
				align : 'center',
				width : 100
			}, {
				title : "机构名称",
				field : "INS_CN_NM",
				align : 'center',
				width : 150
			}, {
				title : "业务名称",
				field : "SERVICE_NAME",
				align : 'center',
				width : 120
			}, {
				title : "业务参数名称",
				field : "SERVICE_PARAM_NAME",
				align : 'center',
				width : 150
			}, {
				title : "交易金额",
				field : "AMT",
				align : 'center',
				width : 100
			}, {
				title : "交易笔数",
				field : "CNT",
				align : 'center',
				width : 50
			},  {
				title : "会员手续费",
				field : "MIDFEE",
				align : 'center',
				width : 100
			}, {
				title : "会员结算手续费",
				field : "CUSTOM_STL_FEE",
				align : 'center',
				width : 100
			}, {
				title : "机构结算手续费",
				field : "INS_STL_FEE",
				align : 'center',
				width : 100
			}, {
				title : "毛利",
				field : "GROSS_PROFIT",
				align : 'center',
				width : 100
			}]
		});
	});

	function doSearch() {
		grid.load({
			stl_dt_start : $('#stl_dt_start').val(),
			stl_dt_end : $('#stl_dt_end').val(),
			ins_cd : $('#ins_cd').val()
		});
		getTotalInfo();
	}
	
	function getTotalInfo(){
		var data = {
				stl_dt_start : $('#stl_dt_start').val(),
				stl_dt_end : $('#stl_dt_end').val(),
				ins_cd : $('#ins_cd').val()
		};
		$.ajax({
			url : '../logStlInsSum/getLogStlInsInfoTotal.do',
			data : data,
			success : function(result) {
				$("#all_amt").html(result.ALL_AMT);
				$("#all_midfee").html(result.ALL_MIDFEE);
				$("#all_custom_stl_fee").html(result.ALL_CUSTOM_STL_FEE);
				$("#all_ins_stl_fee").html(result.ALL_INS_STL_FEE);
				$("#all_gross_profit").html(result.ALL_GROSS_PROFIT);
			}
		});
	}
	
	function exportFile(url){
		var checkedItems = $('#menuTableId').datagrid('getChecked');
		if(!checkedItems){
			return false;
		};
		var ids = "";
		for(var i = 0 ; i < checkedItems.length; i++){
			ids = ids + "," + ((checkedItems[i]).STL_DT+"_"+(checkedItems[i]).SERVICE_PARAM_UUID+"_"+(checkedItems[i]).INS_UUID);
		}
		ids = replaceFirst(ids);
		commonFileDownload(url+ids, "menuForm");
	}
</script>
</html>
